package com.service.impl;


import com.domain.Message;
import com.entity.PageResult;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.mapper.MessageMapper;
import com.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl implements MessageService {
    @Autowired
    private MessageMapper messageMapper;

    //显示留言
    @Override
    public PageResult searchMessage(int pageNum, int pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum,pageSize);
        //调用dao
        Page<Message> messagePage=messageMapper.searchMessage();
        return new PageResult(messagePage.getTotal(),messagePage.getResult());
    }

    //删除留言
    @Override
    public void delMessage(Integer id) {
    messageMapper.delMessage(id);
    }

    //增加留言
    @Override
    public Integer addMessage(Message message) {
        return messageMapper.addMessage(message);
    }

    //查看留言
    @Override
    public Message findById(String id) {
        return messageMapper.findById(id);
    }

//    @Override
//    public Integer editMessage(Message message) {
//        return messageMapper.editMessage(message);
//    }


}
